/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.acworks.acroute.v2.impl;

import com.acworks.acroute.v2.ArcDirectionType;
import com.acworks.acroute.v2.Node;

/**
 *
 * @author nikita
 */
public class ArcCacheKey {

    final private Node node;
    final private ArcDirectionType arcDirectionType;

    public ArcCacheKey(Node node, ArcDirectionType type) {
        assert node != null;
        this.node = node;
        this.arcDirectionType = type == null ? ArcDirectionType.ANY : type;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ArcCacheKey other = (ArcCacheKey) obj;
        if (this.getNode() != other.getNode() && (this.getNode() == null || !this.node.equals(other.node))) {
            return false;
        }
        if (this.arcDirectionType != other.arcDirectionType) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + (this.getNode() != null ? this.getNode().hashCode() : 0);
        hash = 71 * hash + this.arcDirectionType.hashCode();
        return hash;
    }

    /**
     * @return the node
     */
    public Node getNode() {
        return node;
    }
}
